import * as T from './types';
import actions from './actions';
import Blank from '@/pages/common/blank';
import icon4Img from '@/assets/image/my/icon_4.png';
import icon6Img from '@/assets/image/my/icon_6.png';
import React, { Component } from 'react';
import Taro, { getCurrentInstance } from '@tarojs/taro';
import WMLoading from '@/pages/common/loading';
import youImg from '@/assets/image/my/you.png';
import { connect } from 'react-redux';
import { Image, ScrollView, Text, View } from '@tarojs/components';
import { store2Props } from './selectors';
import { WMkit } from 'wmkit';
import './index.less';
import className from 'classnames';

actions().actions.loadReducer();
// @ts-ignore
@connect<Partial<T.IProps>, any>(store2Props, actions)
export default class Index extends Component<Partial<T.IProps>, any> {
  constructor(props) {
    super(props);
    this.state = {};
  }

  componentDidShow() {
    this.props.actions.init();
  }

  componentWillUnmount() {
    this.props.actions.clean();
  }

  async btnClick() {
    Taro.clearStorageSync();
    Taro.switchTab({
      url: '/pages/index/index',
    });
  }

  async pwdClick() {
    let itemStr = Taro.getStorageSync('b2b-wechat@login');
    if (!itemStr) {
      Taro.navigateTo({
        url: '/pages/package-C/login/login/index',
      });
      return;
    }
    Taro.navigateTo({
      url: '/pages/package-A/customer/user-pay/index',
    });
  }

  render() {
    let itemStr = Taro.getStorageSync('b2b-wechat@login');
    let {
      main: { passwordType },
      actions: { action },
    } = this.props;
    return (
      <View className="packageCSetting">
        <View
          className="wrap"
          onClick={() => {
            Taro.navigateTo({
              url: `/pages/package-A/message/index`,
            });
          }}
        >
          <View className="row">
            <Text className="textStyle">手机</Text>
          </View>
          <Text className="phone">{itemStr.user.phone}</Text>
        </View>
        <View
          className="wrap"
          onClick={() => {
            this.pwdClick();
          }}
        >
          <View className="row">
            <Text className="textStyle">支付密码</Text>
          </View>
          <View className="row">
            <Text className="rText">{passwordType ? '已设置' : '未设置'}</Text>
            <Image className="right" src={youImg} mode="widthFix" />
          </View>
        </View>
        {/* <View className="bottom">
          <View className="btn_box">
            <Text
              className="btn-release"
              onClick={() => {
                this.btnClick();
              }}
            >
              注销
            </Text>
          </View>
        </View> */}
      </View>
    );
  }
}
